<?php
include'./functions.php';
$str = <<<str
<div>
	<a href="http://www.baidu.com">百度</a>
</div>
<div>
	<a href="http://www.sina.com">sina</a>
</div>
<span><a href="http://www.sina.com">sina</a></span>
<a href="http://www.sina.com">sina</a>
str;
//定义正则
$preg='/<div>(.*?)<a href=".*?>/is';
//var_dump(preg_match($preg, $str));

echo preg_replace($preg,'<div>\1<a href="http://www.houdunwang.com">', $str);



?>